package com.ada.apps;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class CApps {

    public static void main(String[] args) {

        LinkedList<Integer> xx=new LinkedList<Integer>();

        for (int i = 1; i < 15; i++) {
            xx.add(i);
        }
        xx.stream().forEach(num-> System.out.print(num+"  "));
        xx.pop();
        System.out.println();
        xx.stream().forEach(num-> System.out.print(num+"  "));
        xx.peek();
        System.out.println();
        xx.stream().forEach(num-> System.out.print(num+"  "));

        xx.poll();
        System.out.println();
        xx.stream().forEach(num-> System.out.print(num+"  "));


        xx.offer(15);
        System.out.println();
        xx.stream().forEach(num-> System.out.print(num+"  "));


        //System.out.println(13%1);

    }

    private static void x() {
        int num = 1000000;
        for (int i = 1; i < 11999; i++) {
            int index=i;
            List<Integer> s = makeV(num, index);
            sum(s);
        }
        LinkedList<Integer> xx=new LinkedList<Integer>();
    }

    private static void sum(List<Integer> s) {
        Integer sumx = s.stream().reduce((sum, item) -> sum + item).get();
        System.out.println(sumx);
    }

    private static List<Integer> makeV(int sum, int num) {
        int size = sum / num;
        LinkedList<Integer> s = new LinkedList<Integer>();
        for (int i = 0; i < size; i++) {
            s.add(num);
        }
        Integer xx = s.getLast() + sum % num;
        s.set(s.size() - 1, xx);
        return s;
    }
}
